#include <iostream>
#include <string>
#include <cstring>
#include <algorithm>
#include <vector>
#include <map>
using namespace std;

int n;
const int bias = 1e4+10;
const int inf  = 0x3f3f3f3f;
int c[bias];
int w[bias];
int dp[bias * 2+10];
int scount,ccount;

int main(){
    cin>>n;
    string s;
    for(int i=1;i<=n;i++){
        cin>>s;
        scount = ccount = 0;
        for(auto& c:s){
            if(c=='c'){
               ccount++;
            }
            if(c=='s'){
               scount++;
            }
        }
        c[i] = scount-ccount;
        w[i] = scount;
    }
    memset(dp,-inf,sizeof(dp));
    dp[bias] = 0;
    for(int i=1;i<=n;i++){
       if(c[i]>=0){
          for(int j=2*bias-1;j>=c[i];j--){
              if(dp[j-c[i]]>-inf)
                dp[j] = max(dp[j],dp[j-c[i]]+w[i]);
          }
       }
       else{
          for(int j=0;j-c[i]<=2*bias;j++){
              if(dp[j-c[i]]>-inf)
                dp[j] = max(dp[j],dp[j-c[i]]+w[i]);
          }
       }
    }
    cout<<dp[bias]<<endl;
    system("pause");
    return 0;
}

